#include "../include/task.h"
#include "../include/threadpool.h"
#include <climits>
#include <cstring>
#include <functional>
#include <glog/logging.h>
#include <iostream>
#include <memory>
#include <unistd.h>
void fc(std::shared_ptr<void> args) { std::cout << "start print" << std::endl; }

struct A {
  int a;
  char b[64];
  int c;
};

class StructArrayEvent : public SharedTask {
  A a;

public:
  StructArrayEvent() { memset(&a, 0, sizeof(A)); }
  void proc();
  ~StructArrayEvent() {}
};

void StructArrayEvent::proc()
{
	memset(&a.b, 1, 65);
}

int main() {
  google::InitGoogleLogging("demo");
  FLAGS_log_dir = "./";
  LOG(INFO) << "test";
  // 初始化为64个线程
  std::cout << "a" << std::endl;
  std::shared_ptr<ThreadPool> Normal(new ThreadPool(4));
  std::cout << "b" << std::endl;
  int a = Normal->Init();
  std::cout << "d" << std::endl;
  int sd = 1;
  for (int j = 0; j < 10; ++j) {
    // shared_ptr不提供所谓针对数组的删除器
    std::shared_ptr<void> pp(new int);
    auto qs = bind(fc, std::placeholders::_1);
    Normal->PostTask(qs, pp);
    sleep(1);
  }
}
